#include "LMM_Info.h"

LMM_Info::LMM_Info() {
	__Alpha = NULL;
	__Beta = NULL;
	__S = 0;
	__P = 0;
};

LMM_Info::LMM_Info(const std::size_t _s) {
	__Alpha = new double [_s + 1];
	__Beta = new double [_s + 1];
	__S = _s;
	__P = 0;
};

LMM_Info::LMM_Info(const double *_a, const double *_b, const std::size_t _s, const std::size_t _p) {
	__Alpha = new double [_s + 1];
	__Beta = new double [_s + 1];
	for(int i = 0; i != _s + 1; i++) {
		__Alpha[i] = _a[i];
		__Beta[i] = _b[i];
	}
	__S = _s;
	__P = _p;
};

LMM_Info::~LMM_Info() {
	if(__Alpha != NULL) {
		delete [] __Alpha;
	}
	if(__Beta != NULL) {
		delete [] __Beta;
	}
};

const double LMM_Info::get_alpha_i(const std::size_t _i) const {
	if(_i > __S) {
		std::cerr << "Out of range when getting LLM_Info's __alpha_i'!" << std::endl;
		std::exit(-1);
	}
	return __Alpha[_i];
};

const double LMM_Info::get_beta_i(const std::size_t _i) const {
	if(_i > __S) {
		std::cerr << "Out of range when getting LMM_Info's __Beta_i'!" << std::endl;
		std::exit(-1);
	}
	return __Beta[_i];
};

const std::size_t LMM_Info::get_s() const {
	return __S;
};

const std::size_t LMM_Info::get_p() const {
	return __P;
};

void LMM_Info::set_alpha(const double* _a) {
	for(int i = 0; i != __S + 1; i++) {
		__Alpha[i] = _a[i];
	}
};

void LMM_Info::set_beta(const double* _b) {
	for(int i = 0; i != __S + 1; i++) {
		__Beta[i] = _b[i];
	}
};

void LMM_Info::set(const double* _a, const double* _b, const std::size_t _s, const std::size_t _p) {
	__Alpha = new double [_s + 1];
	__Beta = new double [_s + 1];
	for(int i = 0; i != __S + 1; i++) {
		__Alpha[i] = _a[i];
		__Beta[i] = _b[i];
		__S = _s;
		__P = _p;
	}
};

const LMM_Info& LMM_Info::operator=(const LMM_Info &_lmm_info) {
	std::size_t s = _lmm_info.get_s();
	if(this != &_lmm_info) {
		__Alpha = new double [s + 1];
		__Beta = new double [s + 1];
		for(int i = 0; i != s + 1; i++) {
			__Alpha[i] = _lmm_info.get_alpha_i(i);
			__Beta[i] = _lmm_info.get_beta_i(i);
			__S = s;
			__P = _lmm_info.get_p();
		}
	}
	return *this;
};
